package com.teacher.mobile.controller;


import com.teacher.common.CommonResult;
import com.teacher.pojo.dto.roleUser.RoleUserAddDto;
import com.teacher.pojo.vo.roleUser.RoleUserGetVo;
import com.teacher.service.IRoleUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户角色表 前端控制器
 * </p>
 *
 * @author zfm
 * @since 2022-08-12
 */
@RestController
@RequestMapping("/pc/role-user")
public class RoleUserController {

    @Autowired
    private IRoleUserService iRoleUserService;

    /**
     * 根据角色id查询所有用户
     *
     * @param id
     * @return
     */
    @GetMapping("/{roleId}")
    @ApiOperation("根据角色id查询所有用户")
    public CommonResult<List<RoleUserGetVo>> getUserByRoleId(@PathVariable("roleId") Long id) {
        return iRoleUserService.getUserByRoleId(id);
    }

    /**
     * 更新角色教师表
     *
     * @param dto
     * @return
     */
    @PostMapping
    @ApiOperation("更新角色教师表")
    public CommonResult<String> update(@RequestBody RoleUserAddDto dto) {
        return iRoleUserService.up(dto);
    }

}

